<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEduTopicsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('edu_topics', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('content')->comment('帖子内容');
            $table->unsignedInteger('zan_num')->default(0)->comment('当前文章的点赞数');
            $table->unsignedInteger('category_id')->comment('帖子所属栏目id')->index();
//            后面加index()是为了给这列加入索引,提高用这列查询的速度
            $table->unsignedInteger('user_id')->comment('文章所属用户id')->index();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('edu_topics');
    }
}
